package com.qf.day12.linkedList;

import java.util.List;
import java.util.Scanner;

public class TextEditorDemo {

    public static void main(String[] args) {

        TextEditorService service = new TextEditorServiceImpl();
        Scanner scanner = new Scanner(System.in);
        while (true){
            System.out.println("1.插入文本\t 2.查询所有\t 3.删除文本\t 4.修改文本\t 5.在指定行插入文本\t 6.退出");
            String next = scanner.next();
            switch (next){
                case "1":
                    System.out.println("输入文本");
                    String line = scanner.next();
                    service.addLine(line);
                    break;
                case "2":
                    List<String> aLl = service.getALl();
//                    aLl.forEach(e-> System.out.println(e));
                    for (String s : aLl) {
                        System.out.println(s);
                    }
                    break;
                case "3":
                    System.out.println("要删除的行数");
                    int i = scanner.nextInt();
                    service.deleteLine(i);
                    break;
                case "4":
                    System.out.println("要修改的行数");
                    int nextInt = scanner.nextInt();
                    System.out.println("修改的文本");
                    String s = scanner.next();
                    service.updateLine(nextInt,s);
                    break;
                case "5":
                    System.out.println("要插入的行数");
                    int i1 = scanner.nextInt();
                    System.out.println("插入的文本");
                    String s1 = scanner.next();
                    service.insertLine(i1,s1);
                    break;
                case "6":
                    System.out.println("退出");
                    return;
                default:
                    System.out.println("输入异常重新输入");
            }
        }

    }

}